package com.example.sls.controller.logistics;

import com.example.sls.pojo.logistics.EquipmentRentals;
import com.example.sls.service.intserfaces.logistics.EquipmentRentalsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 设备租借记录表(EquipmentRentals)表控制层
 *
 * @author 蓝江富
 * @since 2024-06-19 13:23:43
 */
@RestController
@RequestMapping("logistics/equipmentRentals")
public class EquipmentRentalsController {
  @Autowired
  EquipmentRentalsService equipmentRentalsService;

  @InitBinder
  public void initDateFormate(WebDataBinder dataBinder) {
    dataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
  }
  @GetMapping("queryById")
  EquipmentRentals queryById(Integer id) {
    return equipmentRentalsService.queryById(id);
  }

  @GetMapping("queryAll")
  List<EquipmentRentals> queryAll() {
    return equipmentRentalsService.queryAllByLimit(new EquipmentRentals(), 999999, 0);
  }
  @GetMapping("queryAllByLimit")
  List<EquipmentRentals> queryAllByLimit(EquipmentRentals equipmentRentals, Integer pageSize, Integer offset) {
    return equipmentRentalsService.queryAllByLimit(equipmentRentals, pageSize, offset);
  }

  @GetMapping("count")
  long count() {
    return equipmentRentalsService.count();
  }

  @GetMapping("insert")
  int insert(EquipmentRentals equipmentRentals) {
    return equipmentRentalsService.insert(equipmentRentals);
  }

  @GetMapping("update")
  int update(EquipmentRentals equipmentRentals) {
    return equipmentRentalsService.update(equipmentRentals);
  }

  @GetMapping("deleteById")
  int deleteById(Integer id) {
    return equipmentRentalsService.deleteById(id);
  }
}

